<?php
namespace Home\Controller;
use Model\SubjectsModel;
use Model\TeacherModel;
use Model\TeachingModel;
use Think\Controller;

class TeacherController extends BaseController {

    public function __construct()
    {
        parent::__construct();

    }

    public function index()
    {
        $teachingModel = new TeachingModel();
        $teachingList = $teachingModel->select();
        $subjectsModel = new SubjectsModel();
        $subjectsList = $subjectsModel->select();
        $this->assign("subjectsList", $subjectsList);
        $this->assign("teachingList", $teachingList);
        $teachingId = intval(I('get.tid'));
        $subjectsId = intval(I('get.sid'));
        if(!empty($teachingId)){
            $data['teachingId'] = $teachingId;
        }else{
            $teachingId = 0;
        }
        if(!empty($subjectsId)){
            $data['subjectsId'] = $subjectsId;
        }else{
            $subjectsId = 0;
        }

        $teacherModel = new TeacherModel();
        $list = $teacherModel->where($data)->order("id desc")->select();
        $this->assign("list",$list);
        $this->assign("tid",$teachingId);
        $this->assign("sid",$subjectsId);
        $this->display();
    }
}